// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者，助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件，未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------

import request from '@/utils/request'

/**
 * 数据tree数据
 * @param pram
 * @param biztype
 */
export function treeCategroy(pram,biztype) {
  const data = {
    //type: pram.type,
    //status: pram.status,
    name: pram.name,
    page: pram.page,
    limit: pram.limit
  }
  let url = ''
  if (biztype === 2) url = `/dep/getDepTree`
  if (biztype === 1) url = `/getCategoryList`
  if (biztype === 4) url = `/getFileTypeList`
  if (biztype === 3) url = `/getDepList`
  return request({
    url: url,
    method: 'GET',
    params: data //get用params
  })
}

export function treeCategroyFile(pram,pid) {
  const data = {
    //type: pram.type,
    //status: pram.status,
    name: pram.name,
    pid: pid
  }
  let url = `/getFileTypeList`
  return request({
    url: url,
    method: 'GET',
    params: data //get用params
  })
}

/**
 * 删除单位
 * @param pram
 */
export function deleteCategroyForDepartment(pram) {
  const data = {
    id: pram.id
  }
  return request({
    url: '/dep/deleteDep',
    method: 'GET',
    params: data //get用params
  })
}

/**
 * 修改 显示关闭状态
 * @param pram
 * @param biztype
 */
export function categroyUpdateStatus(pram,biztype) {
  const data = {
    id: pram.id,
    status: pram.status
  }
  let url = ''
  if (biztype === 3) url = `/dep/updateDepStatus`
  if (biztype === 2) url = `/phoneData/updatePhoneStatus`
  if (biztype === 1) url = `/categoryStatus`
  return request({
    url: url,
    method: 'GET',
    params: data //get用params
  })
}

/**
 * 新增分类
 * @param pram
 * @param biztype
 */
export function addCategroy(pram,biztype) {
  let url = ''
  let data = {}

  if(biztype === 3){
    url = '/dep/insertDep'
    data = {
      name: pram.name,
      shortName: pram.shortName,
      pid: pram.pid,
      sort: pram.sort,
      status: pram.status,
      isCards: pram.isCards,
      level: pram.level,
      id: pram.id,
      responsibleUnit:pram.responsibleUnit
    }
  }else{
    if(biztype == 2) url = '/phoneData/insertAndUpdatePhone'
    if(biztype == 1) url = '/editCategory'

    data = {
      //extra: pram.extra,
      name: pram.name,
      pid: pram.pid,
      sort: pram.sort,
      status: pram.status,
      id: pram.id,
      responsibleUnit:pram.responsibleUnit,
      content:pram.content
    }
  }

  return request({
    url: url,
    method: 'POST',
    data: data
  })
}

/**
 * 人员category数据
 */
export function categoryList() {
  return request({
    url: `/person/getDropList`,
    method: 'GET',
  })
}
//审核
export function adminExamineApi(params) {
  return request({
    url: `/adminExamine`,
    method: 'GET',
    params
  })
}
//闭环状态
export function updateComplaintCircleStatusApi(params) {
  return request({
    url: `updateComplaintCircleStatus`,
    method: 'post',
    params
  })
}
//所属行业重新归类
export function updateReclassifyIndustryApi(params) {
  return request({
    url: `/complaint/updateReclassifyIndustry`,
    method: 'post',
    params
  })
}
//分发
export function allocationApi(params) {
  return request({
    url: `/allocation`,
    method: 'GET',
    params
  })
}
//文件上传
// export function allocationApi(params) {
//   return request({
//     url: `/allocation`,
//     method: 'GET',
//     params
//   })
// }



/**
 * 人员基本数据下拉项
 */
export function personOption() {
  return request({
    url: `/person/getPersonTitleList`,
    method: 'GET',
  })
}

/**
 * 人员军事训练数据
 */
export function categoryTrainList() {
  return request({
    url: `/train/getDropList`,
    method: 'GET',
  })
}

/**
 * 人员电子设备category数据
 */
export function getIndustryList() {
  return request({
    url: `/getIndustryList`,
    method: 'GET',
  })
}

/**
 * 问题类型
 */
export function categoryElcAccountList() {
  return request({
    url: `/selectTypeList`,
    method: 'GET',
  })
}

/**
 * 派件时限
 */
export function categoryTermList() {
  return request({
    url: `/selectTermList`,
    method: 'GET',
  })
}

/**
 * 事件category数据
 */
export function categoryIncList() {
  return request({
    url: `/inc/getDropList`,
    method: 'GET',
  })
}

/**
 * 型号category数据
 */
export function categoryModelTypeList() {
  return request({
    url: `/type/getDropList`,
    method: 'GET',
  })
}

/**
 * 试验category数据
 */
export function categoryTestsList() {
  return request({
    url: `/tests/getDropList`,
    method: 'GET',
  })
}

/**
 * 人员电子设备category数据
 */
export function categoryPointList() {
  return request({
    url: `/point/getDropList`,
    method: 'GET',
  })
}


/**
 * 分类详情
 * @param pram
 */
export function infoCategroy(pram) {
  const data = {
    id: pram.id
  }
  return request({
    url: '/admin/category/info',
    method: 'GET',
    params: data
  })
}

/**
 * 删除分类
 * @param pram
 */
export function deleteCategroy(pram) {
  const data = {
    id: pram.id
  }
  return request({
    url: '/admin/category/delete',
    method: 'GET',
    params: data
  })
}

/**
 * 分类列表
 * @param pram
 */
export function listCategroy(pram) {
  const data = {
    limit: pram.limit,
    name: pram.name,
    page: pram.page,
    pid: pram.pid,
    status: pram.status,
    //type: pram.type

  }
  return request({
    url: '/admin/category/list',
    method: 'GET',
    params: data
  })
}

/**
 * 根据id集合查询对应分类列表
 * @param pram
 */
export function categroyByIds(pram) {
  const data = {
    ids: pram.ids
  }
  return request({
    url: '/admin/category/list/ids',
    method: 'GET',
    params: data
  })
}



/**
 * 文章详情
 * @param pram
 */
export function articleInfoApi(params) {
  return request({
    url: `/admin/article/info`,
    method: 'GET',
    params
  })
}
export function updateRecordApi(params) {
  return request({
    url: `/updateRecord`,
    method: 'GET',
    params
  })
}
//修改是否为有效线索
export function updateClueApi(params) {
  return request({
    url: `/updateClue`,
    method: 'GET',
    params
  })
}
